package com.hybao.login.controller;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.hybao.service.login.LoginService;

@Controller
@RequestMapping("/register")
public class RegisterController{
	@Autowired
	private LoginService loginService;
	public LoginService getLoginService() {
		return loginService;
	}

	public void setLoginService(LoginService loginService) {
		this.loginService = loginService;
	}
	@RequestMapping(method = RequestMethod.POST)
	public @ResponseBody String register(HttpServletRequest request, HttpServletResponse response) {
		String reqRes = "";
		String userName = request.getParameter("userName");
		String userPasswd = request.getParameter("password");
		String userEmail = request.getParameter("email");
		String phone = request.getParameter("phone");
		String birth = request.getParameter("birth");
		Map<String,String> userInfoMap = new HashMap<String,String>();
		userInfoMap.put("userName", userName);
		userInfoMap.put("userPasswd", userPasswd);
		userInfoMap.put("userEmail", userEmail);
		userInfoMap.put("phone", phone);
		userInfoMap.put("birth", birth);
		loginService.createUserInfo(userInfoMap);
		return reqRes;
	}
}
